package cheme.ProcessModel.Cmds;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;

import cheme.ProcessModel.ProcessModel;
import cheme.ProcessModel.SimpleLogger;

public class ContentsModelChangeConstraintCmd extends Command
{
	private static String me = "cheme.ProcessModel.Cmds.ContentsModelChangeConstraintCmd";
	
	private ProcessModel pmModel;
	private Rectangle newconstraint;
	private Rectangle oldConstraint;

	public void execute()
	{
		SimpleLogger.log(me, me + ".execute()");
		
		pmModel.setConstraint(newconstraint);
	}

	public void setConstraint(Rectangle rect)
	{
		SimpleLogger.log(me, me + ".setConstraint(rect)");
		
		newconstraint = rect;
	}

	public void setModel(Object model)
	{
		SimpleLogger.log(me, me + ".setModel(model)");
		
		pmModel = (ProcessModel) model;
		oldConstraint = pmModel.getConstraint();
	}

	public void undo()
	{
		SimpleLogger.log(me, me + ".undo()");
		
		pmModel.setConstraint(oldConstraint);
	}

}
